package com.horay.springbootdemo.hibernate.validator.annotation.validator;

import com.horay.springbootdemo.hibernate.validator.annotation.IdentityCardNumber;
import com.horay.springbootdemo.hibernate.validator.common.IdCardValidatorUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * Class description
 *
 * @author heyingcheng
 * @date 2019/10/1 21:19
 */
public class IdentityCardNumberValidator implements ConstraintValidator<IdentityCardNumber, Object> {

    @Override
    public void initialize(IdentityCardNumber identityCardNumber) {
    }

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        return IdCardValidatorUtils.isIdCard(String.valueOf(o));
    }
}